﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _3._27讲解
{
    /// <summary>
    /// 打折策略选择
    /// </summary>
    public class CashStrategy
    {
        private CashSuper _cs;
        private double _rebate;

        //满减条件
        private decimal _moneyCondition = 0.0M;
        //满减立返金额
        private decimal _moneyReturn = 0.0M;

        public CashStrategy(string type,double rebate = 1,decimal moneyCondition=0M,decimal moneyReturn = 0M)
        {
            switch (type)
            {
                case "Nomal":
                    this._cs = new CashNormal();
                    break;
                case "Rebate":
                    this._cs = new CashRebate(rebate);
                    break;
                case "Return":
                    this._cs = new CashReturn(moneyCondition, moneyReturn);
                    break;
            }
        }
        public decimal GetTotal(decimal money) {

            return _cs.AcceptCash(money);
        }

    }
}
